import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
	roles: ['admin','editor']    control the page roles (you can set multiple roles)
	title: 'title'               the name show in sidebar and breadcrumb (recommend set)
	icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
	breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
	activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
	{
		path: '/login',
		component: () => import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/bigscreen',
		component: () => import('@/views/bigScreen/index'),
		hidden: true
	},

	{
		path: '/404',
		component: () => import('@/views/404'),
		hidden: true
	},

	{
		path: '/',
		component: Layout,
		redirect: '/home',
		children: [{
			path: 'home',
			name: '首页',
			component: () => import('@/views/dashboard/index'),
			meta: { title: '首页', icon: 'dashboard' }
		}]
	},
	{
		path: 'external-link',
		redirect: '/app',
		component: Layout,
		children: [
			{
				name:"app",
				path: '/app',
				meta: { title: '项目管理', icon: 'el-icon-s-help' },
				component: () => import('@/views/project/index'),
				
			}
		]
	},
	{
		path: '/form',
		redirect: '/device',
		component: Layout,
		children: [
			{
				path: '/device',
				name: 'Device',
				component: () => import('@/views/device/index'),
				meta: { title: '设备管理', icon: 'form' }
			}
		]
	},
	{
		path: '',
		redirect: '/user',
		component: Layout,
		children: [
			{
				path: '/user',
				name: 'User',
				component: () => import('@/views/user/index'),
				meta: { title: '用户管理', icon: 'user' }
			}
		]
	},

	
	

	{
		path: '/jiance/cross_section',
		component: Layout,
		redirect: '/jiance/cross_section',
		children: [
			{
				path: '/jiance/cross_section',
				component: () => import('@/views/cross/index'), // Parent router-view
				name: 'CrossIndex',
				meta: { title: '断面',icon: 'tree' },
				
			},
			
		]
	},

	{
		path: '/jiance/namber',
		component: Layout,
		children: [
			{
				path: '/jiance/namber',
				component: () => import('@/views/namber/index'), // Parent router-view
				name: 'CamberIndex',
				meta: { title: '孔号', icon: 'el-icon-s-finance' }
			}
		]
	},
	{
		path: '/jiance/dam_body',
		component: Layout,
		children: [
			{
				path: '/jiance/dam_body',
				component: () => import('@/views/dam_body/index'), // Parent router-view
				name: 'DambodyIndex',
				meta: { title: '坝体', icon: 'el-icon-s-marketing' }
			}
		]
	},
	{
		path: '/jiance/dry_beach',
		component: Layout,
		children: [
			{
				path: '/jiance/dry_beach',
				component: () => import('@/views/dry_beach/index'), // Parent router-view
				name: 'DrybeachIndex',
				meta: { title: '干滩', icon: 'el-icon-s-cooperation' }
			}
		]
	},
	{
		path: '/jiance/view',
		component: Layout,
		children: [
			{
				path: '/jiance/view',
				component: () => import('@/views/totalData/view'), // Parent router-view
				name: 'DrybeachIndex',
				meta: { title: '示意图', icon: 'el-icon-s-cooperation' }
			}
		]
	},
	{
		path: '/jiance/super_high',
		component: Layout,
		children: [
			{
				path: '/jiance/super_high',
				component: () => import('@/views/super_high_device/index'), // Parent router-view
				name: 'SuperhighdeviceIndex',
				meta: { title: '超高', icon: 'el-icon-s-management' }
			}
		]
	},
	

	{
		path: 'external-link',
		component: Layout,
		children: [
			{
				path: '/',
				meta: { title: '系统配置', icon: 'link' }
			}
		]
	},

	{
		path: '/example',
		component: Layout,
		redirect: '/example/table',
		name: 'Example',
		meta: { title: '数据管理', icon: 'el-icon-s-help' },
		children: [
			{
				path: '/data/history',
				name: '历史数据',
				component: () => import('@/views/data/index'),
				meta: { title: '历史数据', icon: 'table' }
			},
			{
				path: '/data/count',
				name: '统计数据',
				component: () => import('@/views/totalData/index'),
				meta: { title: '统计数据', icon: 'tree' }
			},
			{
				path: '/data/warning',
				name: '统计数据',
				component: () => import('@/views/totalData/warning'),
				meta: { title: '报警数据', icon: 'tree' }
			}
		]
	},


	// 404 page must be placed at the end !!!
	{ path: '*',component: Layout, redirect: '/404' }
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({ y: 0 }),
	routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router
